import { _window } from '@/global'
import { isStringNumber, typeCheck } from './types'

/**
 * 添加css样式单位
 * @param value
 * @param defaultUnit
 * @returns
 */
export function addUnit(value?: string | number, defaultUnit = 'px'): any {
  if (!value) return ''
  if (typeCheck(value, 'number') || isStringNumber(value)) {
    return `${value}${defaultUnit}`
  } else if (typeCheck(value, 'string')) {
    return value
  }
  _window._log.warn(`binding value(${value}) must be a string or number`)
}
